#include "main.h"
#include "Global.h"
#include "Functions.h"
#include "CBlock.h"

CBlock::CBlock(){
	Init(NULL);
	m_objectid=101;
	m_pSprite=NULL;
};


CBlock::CBlock(ENTITY_PARAMS* params, CSprite* _sprite){
	Init(params);
	m_objectid=101;
	m_pSprite=_sprite;

	//((CCollider_AABB*)m_pCollider)->SetSize(V(getWidth()+1.0f,getHeight()));

	m_pCollider->SetCollisionType(Static);

};


CBlock::~CBlock(){};

void CBlock::Step(CEntityList *_EntList, BYTE _keys[256], DIMOUSESTATE _mouse){
	if(!(m_state & Immovable)){
		m_pos+=m_accel;//Actually Velocity, not Acceleration
		m_pos.x = min(max(m_pos.x, m_halfwidth), LEVEL_WIDTH-m_halfwidth);
		m_pos.y = min(max(m_pos.y, m_halfheight), LEVEL_HEIGHT-m_halfheight);
	}
};



void CBlock::Draw(Sprites* _Sprite){
	//if(sprite!=NULL)
	DrawTileset(_Sprite->Level->TSBuilding1,4, 4,m_pos, m_scale, 0, CLR_WHITE);

	CCollider_AABB* pTemp;
	pTemp = (CCollider_AABB*) m_pCollider;

	DrawRect( m_pos, pTemp->m_w, pTemp->m_h, D3DCOLOR_RGBA(0,0,0,0), 1, D3DCOLOR_RGBA(0,0,255,255));
};
